# ==================== 第一阶段：基础环境构建 ====================
FROM rockylinux:9.3.20231119 AS base
LABEL maintainer="2908016769@qq.com"
LABEL description="Rocky Linux 9 + Java 21 + Middlewares (MySQL8/Redis6/Nacos2/RabbitMQ/Kafka/RocketMQ)"

RUN set -eux; \
    export HISTCONTROL=ignoredups; \
    echo "max_parallel_downloads=10" >> /etc/dnf/dnf.conf; \
    echo "timeout=60" >> /etc/dnf/dnf.conf; \
    echo "fastestmirror=1" >> /etc/dnf/dnf.conf; \
    \
    dnf clean all; \
    dnf makecache; \
    \
    # 安装 dnf-plugins-core
    dnf install -y dnf-plugins-core; \
    \
    # 启用 CRB 仓库
    dnf config-manager --set-enabled crb || dnf config-manager --set-enabled crb-base; \
    \
    # 安装 EPEL 源
    dnf install -y --nogpgcheck https://mirrors.aliyun.com/epel/epel-release-latest-9.noarch.rpm; \
    dnf makecache; \
    \
    # 安装基础工具 + 替换 curl-minimal
    dnf install -y --allowerasing \
        gcc gcc-c++ make cmake wget curl tar unzip vim net-tools \
        openssl-devel ncurses-devel libaio-devel numactl-libs \
        python3 python3-pip; \
    \
    # 验证 pip3 是否正常
    python3 --version && pip3 --version; \
    \
    # 安装 supervisor
    pip3 install --no-cache-dir --timeout 120 supervisor; \
    \
    # 清理缓存减小体积
    dnf clean all; \
    rm -rf /var/cache/dnf/*
